MODIFYCT Procedure

The MODIFYCT procedure modifies either a user-designated color table file or the distribution color table file colors1.tbl, located in the \resource\colors subdirectory of the main IDL directory.

This routine is written in the IDL language. Its source code can be found in the file modifyct.pro in the lib subdirectory of the IDL distribution.

Examples

Clear out most of IDL's default color table, and add a new color table.

  1. Delete all of the color tables except the first 5:

    for i=74,5,-1 do MODIFYCT, i, ''

    Note that we do the removal in reverse order, so that the index is still valid for each removal.

  2. Use the XPALETTE utility to create a new color table. Then obtain the red, green, and blue vectors:

    TVLCT, red, green, blue, /GET

  3. Add this modified color table to IDL’s list of predefined color tables:

    MODIFYCT, 5, 'My Custom Colors', red, green, blue

  4. Display the results with XLOADCT:

    XLOADCT

    The modified color table has been added to IDL’s list of pre-defined color tables as shown in the following figure:

Syntax

MODIFYCT, Itab, Name, R, G, B [, FILE=filename]

Arguments

Itab

The index of the table to be updated, numbered from 0 to 255. If the specified entry is greater than the next available location in the table, the entry will be added to the table in the available location rather than the index specified by Itab. On return, Itab contains the index for the location that was modified or extended. The modified table can be then be loaded with the IDL command: LOADCT, Itab.

Name

A string, up to 32 characters long, that contains the name for the new color table.

Note: If Name is set to an empty string, then the color table at index Itab is permanently removed from the file and all of the following color tables are shifted up by one position. If you are modifying IDL's default color table file, you may want to make a backup copy first. When removing color tables, the R, G, and B arguments do not need to be supplied.

Warning: Many direct graphics programs use LOADCT with a hard coded value for their desired color table. Removing color tables from IDL's default color table may impact these programs and cause a "random" color table to be loaded.

R

A 256-element vector that contains the values for the red colortable. If Name is an empty string, this argument is ignored.

G

A 256-element vector that contains the values for the green colortable. If Name is an empty string, this argument is ignored.

B

A 256-element vector that contains the values for the blue colortable. If Name is an empty string, this argument is ignored.

Keywords

FILE

Set this keyword to the name of a colortable file to be modified. By default, MODIFYCT changes the distribution color table file colors1.tbl, located in the \resource\colors subdirectory of the main IDL directory.

Version History

Original

Introduced

9.0

Allow color tables to be removed.

See Also

LOADCT, XLOADCT